package com.monboo.album.common {

	/**
	 * @author robin
	 */
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	
	public class AlbumAction {
		public static function isenabled(btMc:DisplayObject,isable:Boolean,fn:Function):void {
			var bt:Object;
			if (isable) {
				if(btMc is Sprite){bt = btMc as Sprite;bt.buttonMode=true;}else{bt = btMc;}
				bt.addEventListener(MouseEvent.CLICK,fn);
				bt.alpha=1;
			} else {
				if(btMc is Sprite){bt = btMc as Sprite;bt.buttonMode=false;}else{bt = btMc;}
				bt.removeEventListener(MouseEvent.CLICK,fn);
				bt.alpha=0.5;
			}
		}
		public static function makeArea(w:uint,h:uint,alpha:Number= 1):Sprite {	
			var area:Sprite = new Sprite;
			area.graphics.beginFill(0x000000,alpha);
			area.graphics.drawRect(0,0,w,h);
			area.graphics.endFill();
			return area;		
		}
		public static function makeGraphics(mc:Sprite,w:uint,h:uint,color:uint=0xffffff ,alpha:Number= 0):void {
			mc.graphics.beginFill(color,alpha);
			mc.graphics.drawRect(0,0,w,h);
			mc.graphics.endFill();			
		}	
		public static function pageState(str:String,current:int,total:int=0):Boolean{
			var state:Boolean;		
			if(str == "pre"){		
				if(current == 0){
					state = true;
				}else{
					state = false;
				}		
			}else if(str == "next"){
				if(current == total){
					state = true;
				}else{
					state = false;
				}		
			}		
			return state;	
		}
	}
}
